import { WindLayer } from 'ol-wind';
export default {
    data() {
        return {
            windsLayer: null
        };
    },
    watch: {
        windsData: {
            handler() {
                this.$nextTick(() => {
                    this.addWinds();
                });
            },
            deep: true,
            immediate: true
        }
    },
    methods: {
        addWinds() {
            this.map.removeLayer(this.windsLayer);
            if (this.windsData.length > 0) {
                this.windsLayer = new WindLayer(this.windsData, {
                    wrapX: true,
                    forceRender: false,
                    windOptions: {
                        velocityScale: 0.005,
                        paths: 2000,
                        colorScale: () => {
                            return '#2DCCFF';
                        },
                        lineWidth: 3
                    }
                });
                this.map.addLayer(this.windsLayer);
            }
        }
    }
};
